﻿using Arena_Server.Infrastructure;
using Common_Library.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common_Library.Parts_of_map;

namespace ScoreModule
{

    public class Score : IScoreModule
    {


        public Dictionary<RobotAvatar, double> GetScore(Common_Library.Map map, List<Move> moveList, Dictionary<int, List<ActionHistory>> globalHistory)
        {

            var scores = new Dictionary<RobotAvatar, double>();
            foreach (var move in moveList)
            {
                var action = move.MadeMove;
                var direction = move.DirectionOfMove;
                int res = 0;

                if (action == MoveType.PickSmallItem && map.GlobalMap[move.Robot.RobotPosition.Y, move.Robot.RobotPosition.X].Color == "Green")
                    res = 10;
                else if (action == MoveType.PickBigItem && map.GlobalMap[move.Robot.RobotPosition.Y, move.Robot.RobotPosition.X].Color == "Green")
                    res = 10;
                else if (action == MoveType.Shoot && move.Consequence == MoveConsequence.ShotAndHitPlayer)
                    res = 5;

                scores.Add(move.Robot, res);
            }

            return scores;
        }
    }


}
